package tg.app.opticket;

import java.rmi.RemoteException;
import psdi.mbo.Mbo;
import psdi.mbo.MboRemote;
import psdi.mbo.MboServerInterface;
import psdi.mbo.MboSet;
import psdi.util.MXException;

/****
 * 
 * @author pzx
 * 
 */
public class OpTaskSet extends MboSet implements OpTaskSetRemote {
	private static final long serialVersionUID = 1L;

	public OpTaskSet(MboServerInterface mboServerInterface)
			throws RemoteException {
		super(mboServerInterface);
	}

	protected Mbo getMboInstance(MboSet mboset) throws MXException,
			RemoteException {
		return new OpTask(mboset);
	}

	public MboRemote addAtIndex(long accessModifier, int ind)
			throws MXException, RemoteException {
		MboRemote mbo = super.addAtIndex(accessModifier, ind);
		setValue("TASKID", ind + 1);
		return mbo;
	}

	public void remove() throws MXException, RemoteException {
		remove(getCurrentPosition());
	}

	public void remove(int pos) throws MXException, RemoteException {
		if ((pos < 0) || (pos > getSize())) {
			return;
		}
		MboRemote targMbo = getMbo(pos);
		remove(targMbo);
	}

	public void remove(MboRemote mbo) throws MXException, RemoteException {
		super.remove(mbo);
	}

	public void deleteAndRemove(MboRemote mbo, long accessModifier)
			throws MXException, RemoteException {
		if (mbo == null) {
			return;
		}
		OpTask ot = (OpTask) mbo;
		ot.setDeleted(false);
		ot.delete(accessModifier);
		remove(ot);
		super.deleteAndRemove(ot, accessModifier);
	}
}
